package com.alei.redis.redisdemo.config;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;

/**
 * @author ShiLei
 * @version v1.0
 * @date 2020-06-27 15:50
 * <p>
 * Jedis 配置类 注入Jedis连接池
 */
@Configuration
public class JedisConfig {

    @Value("${spring.redis.host}")
    private String host;

    @Value("${spring.redis.port}")
    private Integer port;

    @Bean
    public JedisPool getJedisPool() {
        //使用默认配置
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        return new JedisPool(config, host, port);
    }
}
